xen/arm: smmuv3: Ensure queue is read after updating prod pointer
authorZhou Wang <wangzhou1@hisilicon.com>
Mon, 22 Aug 2022 15:52:31 +0000 (16:52 +0100)
committerJulien Grall <jgrall@amazon.com>
Tue, 6 Sep 2022 16:43:07 +0000 (17:43 +0100)
commit56995f06fe9f4f253377189f6fd3f5ddfe3ce881
treeef21890fb7eb15e59e18e0f6bb7a74262c185c47
parent1b11b5ab42a1592c914a772a43860fc03d74ed43
xen/arm: smmuv3: Ensure queue is read after updating prod pointer

Backport Linux commit a76a37777f2c. Introduce _iomb() in the smmu-v3.c
file with other Linux compatibility definitions.

Reading the 'prod' MMIO register in order to determine whether or
not there is valid data beyond 'cons' for a given queue does not
provide sufficient dependency ordering, as the resulting access is
address dependent only on 'cons' and can therefore be speculated
ahead of time, potentially allowing stale data to be read by the
CPU.

Use readl() instead of readl_relaxed() when updating the shadow copy
of the 'prod' pointer, so that all speculated memory reads from the
corresponding queue can occur only from valid slots.

Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>
Link: https://lore.kernel.org/r/1601281922-117296-1-git-send-email-wangzhou1@hisilicon.com
[will: Use readl() instead of explicit barrier. Update 'cons' side to match.]
Signed-off-by: Will Deacon <will@kernel.org>
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a76a37777f2c
Signed-off-by: Rahul Singh <rahul.singh@arm.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
xen/drivers/passthrough/arm/smmu-v3.c